<?php

namespace app\api\admin\v1\provider;

use extend\docker\Images;

class CloudimagesProvider
{
    /**
     * 镜像列表
     * @return array
     * @throws \Exception
     */
    public function getLists()
    {
        $list = (new Images())->getList();
        $imagesList = [];
        foreach($list as $k => $v){
            if($v['repotags'][0] ?? ""){
                $imagesList[] = [
                    'id' => substr(explode(':', $v['id'])[1], 0, 12),
                    'parentid' => $v['parentid'],
                    'image_name' => $v['repotags'][0] ?? "",
                    'size' => round(($v["size"] / 1024 / 1024), 2).'MB',
                    'create_time' => $v['created']
                ];
            }
        }
        return $imagesList;
    }
}